package com.example.common.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author DestinyCc
 * @date 2022/4/28
 */
@Data
@NoArgsConstructor
public class CodeQualityForPR implements Serializable {
    /**
     * 文件名
     */
    String filename;

    Quality prev;

    Quality curr;

    Quality deviation;

    @Data
    @AllArgsConstructor
    @Builder
    public static class Quality implements Serializable{
        /**
         * 复杂性
         */
        Double complexity;

        /**
         * 继承性
         */
        Double inheritance;

        /**
         * 可维护性
         */
        Double maintainability;

        /**
         * 可读性
         */
        Double readability;

        /**
         * 可复用性
         */
        Double reuseablity;

        /**
         * 可测试性
         */
        Double testability;

        /**
         * 可扩展性
         */
        Double extendability;

        /**
         * 安全性
         */
        Double security;

        public Quality compare(Quality prev){
            return new Quality(this.complexity-prev.getComplexity(),
                    this.inheritance-prev.getInheritance(),
                    this.maintainability-prev.getMaintainability(),
                    this.readability-prev.getReadability(),
                    this.reuseablity-prev.getReuseablity(),
                    this.testability-prev.getTestability(),
                    this.extendability-prev.getExtendability(),
                    this.security-prev.getSecurity());
        }
    }
}
